<template>
	<view class="content">
		<u-cell-group>
			<u-cell-item  title="医师姓名" :value="form.doctorName" @click="changename"></u-cell-item>
			<u-cell-item  title="医师科室" :value="form.deptId" @click="changedept"></u-cell-item>
			<u-cell-item  title="医师机构" :value="form.orgName" @click="changeorgName"></u-cell-item>
			<u-cell-item  title="医师职位" :value="form.levelName" @click="changelevelName"></u-cell-item>
		</u-cell-group>
		<u-popup v-model="showname" mode="center" border-radius="14">
			<view>
				<u-field
					v-model="nameinfo"
					label="姓名"
					placeholder="请填写医师姓名">
				</u-field>
				<view class="thisbutton">
					<u-button type="primary" @click="confirmupdate">确认</u-button>
				</view>
			</view>
		</u-popup>
		<u-popup v-model="showorgname" mode="center" border-radius="14">
			<view>
				<u-field
					v-model="orginfo"
					label="机构"
					placeholder="请填写机构">
				</u-field>
				<view class="thisbutton">
					<u-button type="primary" @click="confirmupdate2">确认</u-button>
				</view>
			</view>
		</u-popup>
		<u-select v-model="showlevelname" :list="levelnamelist" @confirm="confirmupdate3"></u-select>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				form:{},
				nameinfo:'',
				orginfo:'',
				showname:false,
				showdept:false,
				showorgname:false,
				showlevelname:false,
				levelnamelist: [
					{
						label: '主任医师',
						value:1
					},
					{
						label: '副主任医师',
						value:2
					},
					{
						label: '主治医师',
						value:3
					},
					{
						label: '医师',
						value:4
					},
					{
						label: '医士',
						value:5
					}
				],
			}
		},
		onLoad(){
			this.form=getApp().globalData.doctorinfo
		},
		methods:{
			changename(){
				this.showname=true
			},
			changedept(){
				
			},
			changeorgName(){
				this.showorgname=true
			},
			changelevelName(){
				this.showlevelname=true
			},
			confirmupdate(){
				this.form.doctorName=this.nameinfo;
				console.log(this.form)
				uni.request({
				    url: getApp().globalData.hostip+'Demo/doctor/update', 
					method: 'POST',
				    data: this.form,
					header: {
						'Content-Type': 'application/json',
					},
					fail:(fa) =>{
						console.log(fa)
					},
				    success: (res) => {
						console.log(res.data)
				    }
				});
			},
			confirmupdate2(){
				this.form.orgName=this.orginfo;
				console.log(this.form)
				uni.request({
				    url: getApp().globalData.hostip+'Demo/doctor/update', 
					method: 'POST',
				    data: this.form,
					header: {
						'Content-Type': 'application/json',
					},
					fail:(fa) =>{
						console.log(fa)
					},
				    success: (res) => {
						console.log(res.data)
				    }
				});
			},
			confirmupdate3(e){
				this.form.levelName=e[0].label;
				uni.request({
				    url: getApp().globalData.hostip+'Demo/doctor/update', 
					method: 'POST',
				    data: this.form,
					header: {
						'Content-Type': 'application/json',
					},
					fail:(fa) =>{
						console.log(fa)
					},
				    success: (res) => {
						console.log(res.data)
				    }
				});
			}
		}
	}
</script>

<style scopped>
	page{
		background-color: #f5f5f5;
	}
	.thisbutton{
		width: 50%;
		padding: 20rpx;
		margin-left: 25%;
	}
</style>
